// widgets/GoodsDetailWidgets/GoodsDetailContWidget/GoodsDetailContWidget.js
//获取应用实例
const app = getApp();
const assetsAddress = app.globalData.global.assetsIp + '/' + app.globalData.global.assetsName;

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    gradeColorList: {
      type: Array, // 商品等级颜色列表
    },
    goods: {
      type: Object, // 商品信息
    },
  },
  /**
   * 组件的初始数据
   */
  data: {
    assetsAddress: assetsAddress,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    selGoods(e){
      let item = e.target.dataset.item||e.currentTarget.dataset.item;
      let name = e.target.dataset.name||e.currentTarget.dataset.name;
      let colorId = e.target.dataset.colorId||e.currentTarget.dataset.colorId;
      console.log(item,'item')
      console.log(this.properties.goods,'goods')
      if(name == 'grade'){
        if(item != this.properties.goods.grade){
          this.triggerEvent('selGoods', JSON.stringify({'id': item, 'name': 'grade','colorId': colorId}),'grade')
        }
      }else if(name == 'colorId'){
        if(item != this.properties.goods.colorId){
          this.triggerEvent('selGoods', JSON.stringify({'id': item, 'name': 'colorId'}),'colorId')
        }
      }
      
    },
    // selGoodsColorId(e){
    //   let item = e.target.dataset.item||e.currentTarget.dataset.item;
    //   console.log(item,'item')
    //   console.log(this.properties.goods,'goods')
      
    // },
  }
})
